import cv2 as cv

cap = cv.VideoCapture(0)

while True:
    ret, frame = cap.read()

    k = cv.waitKey(1)
    if k == 27:
        break
    elif k == ord('s'):
        cv.imwrite('saved_capture.jpg', frame)

    cv.imshow("capture", frame)
    
cap.release()
cv.destroyAllWindows()

